<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <el-button type="primary" @click="testReq">请求测试</el-button>
    <el-button type="danger" @click="testError">异常测试</el-button>
    <el-button type="success" @click="proxyTest">代理测试</el-button>
    <el-button type="success" @click="proxyTest1">代理测试1</el-button>
    <el-button type="success" @click="nginxProxyTest">nginx代理测试</el-button>
    <p>请求测试结果：{{test}}</p>
    <p>异常测试结果：{{errMsg}}</p>

  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data(){
    return{
      test: '',
      errMsg: ''
    }
  },
  methods:{
    testReq(){
      this.$message.success('这是一个成功的消息')
      this.$http.get('/testApis/testApi1').then(res=>{
        console.log(res)
        this.test = res.data
      }).catch(error=>{
        console.log('test error===>', error);
      })

    },
    testError(){
      this.$http.get('/testApis/testApi3').then(res=>{
        this.errMsg = res
      }).catch(error=>{
        console.log('test error111===>', error)
      })
    },
    proxyTest(){
      this.$http.get('/testApis/testApi4').then(res=>{
        this.$message.warning('警告：代理请求，返回值===>'+ res.data)
      }).catch(error=>{
        console.log('proxyTest error===>', error)
      })
    },
    proxyTest1(){
      this.$http.get('/testApis/testApi4').then(res=>{
        this.$message.warning('警告：代理请求，返回值===>'+ res.data)
      }).catch(error=>{
        console.log('proxyTest error===>', error)
      })
    },
    nginxProxyTest(){
      this.$http.get('/testApis/test/devops/testApi6').then(res=>{
        this.$message.warning('警告：nginx代理请求，返回值===>'+ res.data)
      }).catch(error=>{
        console.log('nginxProxyTest error===>', error)
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
